home *** CD-ROM | disk | FTP | other *** search
- #include "../CGVPMacro.csi"
-
- PS20Only
-
- MainInput { uniform sampler2D baseMap : texunit0,
- uniform sampler2D bumpMap : texunit1,
- uniform samplerCUBE normCubeMapLV : texunit2,
- uniform samplerCUBE normCubeMapHA : texunit3,
- uniform samplerCUBE projMap : texunit4,
- uniform sampler2D attenMap : texunit5,
- uniform samplerCUBE envMap : texunit6,
- uniform float4 Ambient,
- uniform float4 Reflect,
- uniform float4 Diffuse,
- uniform float4 Specular }
- DeclarationsScript
- {
- OUT_T0_T1_T2_T3_T4_T5_T6_C0
- FOUT
- }
- CoreScript
- {
- // load the decal
- half4 decalColor = tex2D(baseMap, IN.Tex0.xy);
- // load the bump normal
- float4 bumpNormal = 2*(tex2D(bumpMap, IN.Tex1.xy)-0.5);
- // load the projector filter map
- half4 projColor = texCUBE(projMap, IN.Tex4.xyz);
- // load the environment map
- half4 envColor = texCUBE(envMap, IN.Tex6.xyz);
- half atten = saturate((2*(IN.Color.b-0.5)) * -(2*(IN.Color.b-0.5)) + (1-tex2D(attenMap, IN.Tex5.xy).b));
-
- // Light vector from normalization cube-map
- float4 lVec = 2*(texCUBE(normCubeMapLV, IN.Tex2.xyz)-0.5);
- // Half angle vector from normalization cube-map
- float4 hVec = 2*(texCUBE(normCubeMapHA, IN.Tex3.xyz)-0.5);
-
- half NdotL = saturate(dot(lVec.xyz, bumpNormal.xyz));
- half NdotH = saturate(dot(hVec.xyz, bumpNormal.xyz));
- half3 dif = (decalColor.xyz * NdotL * atten * Diffuse.xyz * projColor.xyz) * 2;
- half specVal = saturate((NdotH - 0.75)*4);
- specVal = specVal * specVal;
- half3 spec = (specVal * atten * projColor.xyz * Specular.xyz) * 2;
- half3 amb = lerp(decalColor.xyz*Ambient.xyz, envColor.xyz, Reflect.x);
-
- // finally add them all together
- OUT.Color.xyz = amb + dif + spec;
- OUT.Color.w = decalColor.w * Ambient.w;
- }
-
-